<template>
  <div class="allcourses">
    <div class="head" @click="clickHandle">
      <i class="yo-ico">&#xe60c;</i><span>"马甲线"的相关课程</span>
    </div>
    <div class="body">
      <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad"
      >
        <!-- <van-cell v-for="item in list" :key="item" :title="item" /> -->
            <Courses v-for="item in list" :key="item" :item="item" ></Courses>
           
      </van-list>
      </van-pull-refresh>
    </div>
    <div class="foot"></div>
  </div>
</template>

<script>
import Courses from "./Courses";

import Vue from 'vue';
import { List , PullRefresh } from 'vant';

Vue.use(List);
Vue.use(PullRefresh);

export default {
  components: {
    Courses,
  },

    data() {
    return {
      list: [],
      loading: false,
      finished: false,
      refreshing: false,
    };
  },
  methods: {
    onLoad() {
      setTimeout(() => {
        if (this.refreshing) {
          this.list = [];
          this.refreshing = false;
        }

        for (let i = 0; i < 10; i++) {
          this.list.push(this.list.length + 1);
        }
        this.loading = false;

        if (this.list.length >= 40) {
          this.finished = true;
        }
      }, 1000);
    },
    onRefresh() {
      // 清空列表数据
      this.finished = false;

      // 重新加载数据
      // 将 loading 设置为 true，表示处于加载状态
      this.loading = true;
      this.onLoad();
    },
    clickHandle(){
    this.$router.back();
    this.$router.push("/index/my/myCourse");
  }
  },
  

};
</script>

<style  lang="stylus" scoped>
.allcourses 
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 0.13rem;
  margin-top: 0.3rem;
  

  .head 
    font-size: 0.2rem;
    font-weight: 900;
    margin-bottom: 0.1rem;
  

  .body 
    flex: 1;
    overflow: scroll;
    .van-list__finished-text
      text-align center
  
  .foot
    width 100%
    height .3rem
        

</style>